<?php

namespace app\api\validate;


use \think\Validate;

/**
 *  用户登录验证类
 */
class User extends Validate
{
    protected $rule = [
        'cusname' => 'length:2,18',
        'qq' => 'number|length:6,18',
        'whatsapp' => 'string',
        'nickname' => 'require|length:2,18',
        'country' => 'string',
        'address' => 'string',
        'phone_code' => 'require',
        'code' => 'require|length:6',
        'phone' => 'require|number',
        'email' => 'require|email',
        'password' => 'require|length:16,32',
        'new_password' => 'require|length:16,32',
        'repeat_password' => 'require|length:16,32',
        'country_id' => 'require|number',
        'avatar_id' => 'require|number'
    ];

    //定义验证提示
    protected $message = [
        'cusname.length' => 'user.cusnameLength',
        'qq.number' => 'user.qqNumber',
        'qq.length' => 'user.qqLength',
        'whatsapp' => 'user.whatsappString',
        'nickname.require' => 'user.nicknameRequire',
        'nickname.length' => 'user.nicknameLength',
        'country' => 'user.countryString',
        'phone_code.require' => 'user.phoneCodeRequire',
        'code.require' => 'user.codeRequire',
        'code.length' => 'user.codeLength',
        'phone.require' => 'user.phoneRequire',
        'phone.number' => 'user.phoneNumber',
        'email.require' => 'user.emailRequire',
        'email.email' => 'user.emailEmail',
        'password.require' => 'user.passwordRequire',
        'password.length' => 'user.passwordLength',
        'new_password.require' => 'user.newPasswordRequire',
        'new_password.length' => 'user.newPasswordLength',
        'repeat_password.require' => 'user.repeatPasswordRequire',
        'repeat_password.length' => 'user.repeatRasswordLength',
        'country_id.require' => 'user.countryIdRequire',
        'country_id.number' => 'user.countryIdNumber',
        'avatar_id.require' => 'user.avatarIdRequire',
        'avatar_id.number' => 'user.avatarIdNumber',
    ];

    //定义验证场景
    protected $scene = [
        'updateInfo' => ['nickname'],
        'updatePhone' => ['phone_code','phone','code'],
        'updateEmail' => ['email','code'],
        'updatePassword' => ['password','new_password','repeat_password']
    ];


}
